<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:include="css :: css">
</head>
<link href="/js/jquery.icheck/skins/square/blue.css" rel="stylesheet">
<link href="/css/chosen.css" rel="stylesheet">
<style>
    .fixed-table-toolbar .bs-bars, .fixed-table-toolbar .search, .fixed-table-toolbar .columns {
        margin-top: -70px;
    }
</style>
<body style="overflow: hidden;opacity: 1">

<div id="cl-wrapper" style="padding-top: 0">
    <div class="container-fluid">
        <div class="cl-mcont">
            <div class="row">
                <div class="col-md-12">
                    <div class="block-flat">
                        <form class="form-horizontal group-border-dashed" id="addAnnouncementForm">
                            <input type="hidden" id="hidOperate" name="operate">
                            <input type="hidden" id="hidId" name="id">
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" class="form-control" placeholder="标题"
                                           id="title" name="title"/>
                                </div>
                                <div class="input-group">
                                    <input type="text" class="form-control" th:width="170px"
                                           placeholder="作者" id="author" readonly
                                           value="豆乐卡" name="author"/>
                                </div>
                                <div class="input-group">
                                    <select class="chosen-select" id="supplyModel" name="modelId"
                                            multiple="multiple">
                                        <option value="">销卡模板</option>
                                    </select>
                                </div>
                                <div class="input-group">
                                    <button class="btn btn-primary" type="button"
                                            style="margin-left: 155px;"
                                            onclick="$('#templateModal').modal('show')">选择模板
                                    </button>
                                </div>
                                <div class="input-group">
                                    <button class="btn btn-default btn-add-notice" type="button"
                                            onclick="addTab('/announcementModel','1','模板管理')">模板管理
                                    </button>
                                </div>
                            </div>
                            <div class="block-flat" style="height: 260px">
                                <div class="content">
                            <textarea type="text" class="form-control" id="content" name="content"
                                      style="height: 232px"></textarea>
                                </div>
                            </div>
                            <div class="block-flat" style="height:250px;padding: 20px;">
                                <input type="radio" value="0" name="state" checked="checked">给谁看
                                <input type="radio" value="1" name="state">不给谁看
                                <textarea id="readable" name="readable"
                                          style="width:93%;margin-top: 10px; height: 66px;"></textarea></br>
                                <span style="color: red">*会员编号之间用“,”隔开，不填写会员 则默认全部接收 </span>
                                <button class="btn btn-primary" type="button" id="submitMessage">
                                    确认发布
                                </button>
                            </div>
                        </form>
                    </div>
                </div>

            </div>
        </div>
        <div class="modal fade" id="templateModal" tabindex="-1" role="dialog" aria-hidden="true"
             data-backdrop="static">
            <div class="modal-dialog" role="document" style="width:800px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="addUserModalLabel">公告模板</h4>
                    </div>
                    <div class="modal-body" style="min-height:460px;">
                        <form class="form-horizontal" role="form" id="addForm">
                            <div class="form-group" style="height:40px;">
                                <label class="col-sm-2 control-label"><span
                                        class="text-danger">*</span>标题</label>
                                <div class="col-sm-10">
                                    <select class="form-control" name="title" id="modelTitle"
                                            onchange="reloadContent(this)">
                                        <option value="">模板标题</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span
                                        class="text-danger">*</span>内容</label>
                                <div class="col-sm-10">
                                <textarea type="text" class="form-control" style="height:160px;"
                                          id="modelContent"
                                          readonly
                                          name="content"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span
                                        class="text-danger">*</span>参数</label>
                                <div class="col-sm-10" id="codeParam">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-10" style="margin-left: 600px;">
                                    <button type="button" class="btn btn-primary" id="clearCode">
                                        重置
                                    </button>
                                    &nbsp;
                                    <button type="button" class="btn btn-primary" id="addCode">传参
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消
                        </button>
                        <button type="button" class="btn btn-primary" id="addModelSubmit">确定
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="js :: js"></div>
<script type="text/javascript" src="/js/kindeditor-4.1.10/kindeditor.js"></script>
<script type="text/javascript" th:attr="src=@{/js/jquery.form.js}"></script>
<script type="text/javascript" th:attr="src=@{/js/jquery.parser.js}"></script>
<script type="text/javascript" src="js/jquery.icheck/icheck.min.js"></script>
<script type="text/javascript"
        src="/js/pageJs/memberManage/writeAnnouncement.js?deVersion=2018178715"></script>
<script type="text/javascript" src="/js/chosen.jquery.js?deVersion=201817109923"></script>
<script>
    $(document).ready(function () {
        var id = GetQueryString("id");
        if (id != null) {
            $.ajax({
                type: "GET",
                url: "UserAnnouncementController/queryAnnouncementById?id=" + id,
                async: false,
                success: function (data) {
                    $("#title").val(data.title);
                    $("#hidOperate").val(0);
                    $("#hidId").val(data.id);
                    $("#content").val(data.content);
                    $("#type").val(data.type);
                    var models = data.modelId.split(",");
                    for (var i = 0; i < models.length; i++) {
                        $("#supplyModel option[value=" + models[i] + "]").attr('selected', 'selected');
                    }
                    $("#supplyModel").trigger("chosen:updated");
                    $.ajax({
                        type: "post",
                        data: {"ids": data.readable},
                        async: true,
                        url: '/UserAnnouncementController/getReadableAccount',
                        success: function (data) {
                            $("#readable").val(data);
                        },
                        error: function (data) {
                            layer.msg("加载会员信息异常");
                        }
                    })
                }
            });
        }

    });

    $("#supplyModel").chosen({
        no_results_text: "无搜索结果",
        allow_single_deselect: true,
        disable_search_threshold: 10,//选项小于10时不显示搜索框
        max_selected_options: 5,//多选情况下最多能选5个
        width: "280px"
    });
    //销卡模板
    var str;
    $.ajax({
        type: "GET",
        url: "productPrice/findModelPrice",
        async: false,
        data: {param: true},
        success: function (data) {
            var group_obj = data;
            for (var i = 0; i < group_obj.length; i++) {
                str += '<option value="' + group_obj[i].id + '">' + group_obj[i].modelName + '</option>'
            }
            $("#supplyModel").append(str).trigger("chosen:updated");
        }
    });
</script>
</body>
</html>
